package touhou.entity;

import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;

import gameframework.base.Drawable;
import gameframework.game.SpriteManager;
import touhou.game.GameMovable;
import touhou.base.Entity;
import touhou.base.Overlappable;
import touhou.game.Projectile;
import touhou.game.SpriteManagerBulletImpl;

/**
 * Projectile du Hero.
 */
public class Bullet extends GameMovable implements Drawable, Entity,
Overlappable, Projectile {
	private SpriteManager spriteManager = null;
	public static final int RENDERING_SIZE = 16;
	protected boolean movable = true;
	private int damage = 5;
	public int id;
	protected static int ID = 0;

	public Bullet(Canvas canvas) {
		id = ID++;
		spriteManager = new SpriteManagerBulletImpl("images/BulletAc2.gif",
				canvas, RENDERING_SIZE, RENDERING_SIZE*2, 12);
	}
	
	public Bullet(Canvas canvas, int damage) {
		id = ID++;
		spriteManager = new SpriteManagerBulletImpl("images/BulletAc2.gif",
				canvas, RENDERING_SIZE, RENDERING_SIZE*2, 12);
		this.damage = damage;
	}

	@Override
	public Rectangle getBoundingBox() {
		return (new Rectangle((int)getPosition().getX(), (int)getPosition().getY(), RENDERING_SIZE, RENDERING_SIZE*2));
	}

	@Override
	public void draw(Graphics g) {
		Point2D p = getPosition();
		spriteManager.draw(g, new Point((int)p.getX(),(int)p.getY()));
		// DEBUG
		//g.drawRect((int)getPosition().getX(), (int)getPosition().getY(), RENDERING_SIZE, RENDERING_SIZE*2);
	}

	@Override
	public void oneStepMoveAddedBehavior() {
		if (movable) {
			spriteManager.increment();
		}
	}

	
	public int getDamage() {
		return damage;
	}
}
